Fix stale cache in Tramp
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 5 Feb 2024 11:54:03 +0000 (12:54 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Mon, 5 Feb 2024 11:54:03 +0000 (12:54 +0100)
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band):
Flush file properties in time.  (Bug#68805)

lisp/net/tramp-sh.el

index 7656da81dccda2d0687bd699a77e8eb4b05b6917..68ee541bee67fa8e4701b636bb0875428600b1e7 100644 (file)
@@ -2009,7 +2009,7 @@ ID-FORMAT valid values are `string' and `integer'."
             #'copy-directory
             (list dirname newname keep-date parents copy-contents))))
 
-       ;; When newname did exist, we have wrong cached values.
+       ;; NEWNAME has wrong cached values.
        (when t2
          (with-parsed-tramp-file-name (expand-file-name newname) nil
            (tramp-flush-file-properties v localname)))))))
@@ -2148,24 +2148,24 @@ file names."
              ;; One of them must be a Tramp file.
              (error "Tramp implementation says this cannot happen")))
 
-           ;; Handle `preserve-extended-attributes'.  We ignore
-           ;; possible errors, because ACL strings could be
-           ;; incompatible.
-           (when-let ((attributes (and preserve-extended-attributes
-                                       (file-extended-attributes filename))))
-             (ignore-errors
-               (set-file-extended-attributes newname attributes)))
-
            ;; In case of `rename', we must flush the cache of the source file.
            (when (and t1 (eq op 'rename))
              (with-parsed-tramp-file-name filename v1
                (tramp-flush-file-properties v1 v1-localname)))
 
-           ;; When newname did exist, we have wrong cached values.
+           ;; NEWNAME has wrong cached values.
            (when t2
              (with-parsed-tramp-file-name newname v2
                (tramp-flush-file-properties v2 v2-localname)))
 
+           ;; Handle `preserve-extended-attributes'.  We ignore
+           ;; possible errors, because ACL strings could be
+           ;; incompatible.
+           (when-let ((attributes (and preserve-extended-attributes
+                                       (file-extended-attributes filename))))
+             (ignore-errors
+               (set-file-extended-attributes newname attributes)))
+
             ;; KEEP-DATE handling.
             (when (and keep-date (not copy-keep-date))
               (tramp-compat-set-file-times
@@ -2437,7 +2437,7 @@ The method used must be an out-of-band method."
            copy-program (tramp-get-method-parameter v 'tramp-copy-program)
            copy-args
            ;; " " has either been a replacement of "%k" (when
-           ;; keep-date argument is non-nil), or a replacement for
+           ;; KEEP-DATE argument is non-nil), or a replacement for
            ;; the whole keep-date sublist.
            (delete " " (apply #'tramp-expand-args v 'tramp-copy-args spec))
            ;; `tramp-ssh-controlmaster-options' is a string instead
@@ -5353,7 +5353,7 @@ connection if a previous connection has died for some reason."
                              "2>" (tramp-get-remote-null-device previous-hop))
                          ?l (concat remote-shell " " extra-args " -i"))
                         ;; A restricted shell does not allow "exec".
-                        (when r-shell '("&&" "exit")) '("||" "exit"))
+                        (when r-shell '("&&" "exit")) '("||" "exit"))
                        " "))
 
                      ;; Send the command.